#include "QuickSort.h"

int main()
{
    vector<int> a, b;
    vector<int>::iterator it;
    double time1, time2;
    int n, m;
    clock_t start, end;

    cout << "Please input the length of the vector：" << endl;//输入向量长度
    cin >> n;
    cout << "Please input the way of forming a vector：" << endl;//输入向量生成方式
    cin >> m;

    for (int i = 0; i < n; i++)
    {
        if (m == 0)
        {
            a.push_back(i);
            b.push_back(i);
        }
        else if (m == 1)
        {
            a.push_back(n - i);
            b.push_back(n - i);
        }
        else
        {
            int tem = rand() % n;
            a.push_back(tem);
            b.push_back(tem);
        }
    }
    cout << "The original vector is： ";//原向量

    for (int i = 0; i < n; i++)
    {
        cout << a[i] << " ";
    }

    cout << "\n";

    start = clock();
    sort(a, 0);
    end = clock();
    time1 = end - start;

    cout << "After sort(random number):" << endl;//随机数作为主元的情况
    for (int i = 0; i < n; i++)
    {
        cout << a[i] << " ";
    }

    start = clock();
    sort(b, 1);
    end = clock();
    time2 = end - start;
    cout << "\n";

    cout << "After sort(middle number):" << endl;//中位数作为主元的情况
    for (int i = 0; i < n; i++)
    {
        cout << b[i] << " ";
    }
    cout << "\ntime for random number：" << time1 << endl;//随机数情况计时
    cout << "\ntime for middle number：" << time2 << endl;//中位数情况计时
}
